package InvestmentPojo;

import java.sql.DriverManager;
import java.util.ArrayList;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import antlr.collections.List;

import com.mysql.jdbc.Connection;
import com.mysql.jdbc.ResultSet;
import com.mysql.jdbc.Statement;

public class LoginTest extends Action{
	 public ActionForward execute(ActionMapping mapping, ActionForm inForm, HttpServletRequest request, HttpServletResponse response) throws Exception {
			String html = "";
			Connection con=null;
			Statement st=null;
			ArrayList al= new ArrayList();
			try{
				Class.forName("org.gjt.mm.mysql.Driver");
				con=(Connection) DriverManager.getConnection("jdbc:mysql://68.178.142.190:3306/InvestmentTest","InvestmentTest","Chakrika123#");
				st=(Statement) con.createStatement();
				ResultSet rs=(ResultSet)st.executeQuery("select * from investment_in_india where form_id = 6 order by option_label");
				while(rs.next()){
					System.out.println("<font color='yellow'>"+rs.getString(3)+"======"+rs.getString(4));
					al.add(rs.getString(3)+"-"+rs.getString(4));					
				}
				request.setAttribute("result", al);	
			}catch(Exception e ){
				if(null != con && null !=st){
					st.close();
					con.close();
				}
				e.printStackTrace();
			}finally{
				if(null != con && null !=st){
					st.close();
					con.close();
				}
			}
			 return mapping.findForward("success");
}
}